/**
 * 	 * @author  Zg
	 * 请求数据处理
	 * @param string url 请求地址
	 * @param string method 请求方式 (默认是 get )
	 *  GET or POST
	 * @param {*} postData 请求参数
	 * @param bool isForm 数据格式
	 *  true: 'application/x-www-form-urlencoded'
	 *  false:'application/json'
	 * @param bool hideLoading 是否隐藏loading
	 *  true: 隐藏
	 *  false:显示
	 */

const baseUrl = 'http://hyk.weifangtianxia.com/';
export const post = (url = '', date = {}, type = 'post', header = {
	'content-type': 'application/x-www-form-urlencoded',
}) => {
    return new Promise((resolve, reject) => {
        uni.request({
            method: type,
            url: baseUrl + url,
            data: date,
			header: header,
            dataType: 'json',         
        }).then((response) => {
            setTimeout(function() {
                uni.hideLoading();
            }, 200);
            let [error, res] = response;		
            resolve(res.data);
        }).catch(error => {
            let [err, res] = error;
            reject(err)
        })
    });
}

export const get = (url = '', date = {}, type = 'GET', header = {
	'content-type': 'application/x-www-form-urlencoded'
}) => {
    return new Promise((resolve, reject) => {
        uni.request({
            method: type,
            url: baseUrl + url,
            data: date,
            header: header,
            dataType: 'json',         
        }).then((response) => {
            setTimeout(function() {
                uni.hideLoading();
            }, 200);
            let [error, res] = response;		
            resolve(res.data);
        }).catch(error => {
            let [err, res] = error;
            reject(err)
        })
    });
}
// export default http